home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-25 | 4.6 KB | 131 lines | [TEXT/MPS ] |
-
- //____________________________________________________________________________________________________
- //
- // Copyright: © 1993 Apple Computer, Inc. All rights reserved.
- //
- // Authors: Scott Searle (original)
- // Victor J. Hnyp (extensions)
- // David A. Lyons (DAL)
- //
- // Date: 12/01/93
- //
- // Revisions
- //
- // 12/01/93 DAL 3.01 Removed address stripping from MY_GET_TRAP_ADDRESS macro.
- // It's important NOT to strip the old trap addresses, because
- // ROM routines are at $40xxxxxx even in 24-bit mode, and there
- // are come-from patches in the system that assume that (like
- // the window-positioning patch, where GetResource sees that it
- // it is being called from GetNewDialog).
- //
- // 02/08/93 VJH 2.03 Changes to the way GetNextItemAddress works
- //
- // 01/18/93 VJH 2.02 Added: N2S and GetNextItemAddress
- //
- // 01/04/93 VJH 2.01 Changed Copyright Notice, added new functions
- //
- // 22-May-92 1.0d1e1 Changed StringCompareMethod from short to long.
- //
- //____________________________________________________________________________________________________
-
- #ifndef __UTILITY__
- #define __UTILITY__
-
- // GENERAL THINGS •••••••••••••••••••••••••••••••••••••••••••••
-
- #define NumToolboxTraps ((NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E, ToolTrap)) ? 0x200 : 0x400)
- #define TrapMask 0x0800
- #define GetTrapType(_theTrap) (((_theTrap) & TrapMask) ? ToolTrap : OSTrap)
-
- #define GESTALT_BIT_TEST(_sel, _res, _bit) ((Boolean)(Gestalt((_sel), &(_res)) == noErr && ((_res) >> (_bit)) & 0x00000001))
- #define GESTALT_COMPARE(_sel, _res, _op, _tst) ((Boolean)(Gestalt((_sel), &(_res)) == noErr && ((short)(_res) _op (short)(_tst))))
-
- #define MY_STRIP_PTR(_p) ((void *) StripAddress((Ptr)(_p)))
- #define MY_STRIP_HDL(_h) ((void **) StripAddress((Ptr)(_h)))
- #define MY_GET_TRAP_ADDRESS(_tNum) (NGetTrapAddress((_tNum), GetTrapType((_tNum))))
- #define MY_SET_TRAP_ADDRESS(_tAddr, _tNum) (NSetTrapAddress((long)MY_STRIP_PTR((_tAddr)), (_tNum), GetTrapType((_tNum))))
-
- #define MY_H_OPEN_RES_FILE(_vRefNum, _dirID, _name, _perm) (HOpenResFile((_vRefNum), (_dirID), MY_STRIP_PTR((_name)), (_perm)))
- #define MY_OPEN_RF_PERM(_name, _wdRefNum, _perm) (OpenRFPerm(MY_STRIP_PTR((_name)), (_wdRefNum), (_perm)))
-
- enum
- {
- commandKeyBit = 48,
- controlKeyBit = 60,
- optionKeyBit,
- alphaLockBit,
- shiftKeyBit
- };
-
- #define MBarHeight (*(short *)(0xBAA))
- #define WindowList (*(WindowPtr*)0x9D6)
- #define CurrentA5 (*(Ptr **)0x904)
- #define thePort (*(GrafPtr*)*CurrentA5)
- #define screenBits ((BitMap *)(*CurrentA5+0xFFFFFF86))
- #define dkGray ((Pattern*)(*CurrentA5 - 40))
- #define gray ((Pattern*)(*CurrentA5 - 24))
- #define black ((Pattern*)(*CurrentA5 - 16))
- #define ltGray ((Pattern*)((char*)gray - 8))
- #define MCenterR(_r) (OffsetRect((_r), (screenBits->bounds.right - (_r)->right - (_r)->left) >> 1, \
- ((screenBits->bounds.bottom - (_r)->bottom - (_r)->top) >> 1) + 10))
- #define NIL ((void *)0L)
- #define C_PORT (0xC000)
- #define HILITE_RGB ((RGBColor*)0xDA0)
- #define CacheCom (*(unsigned char *)0x39C)
- #define DAStrings (*(Handle *)0xAA0)
- #define CurApName ((unsigned char*)0x910)
- #define CurApRefNum (*(short*)0x900)
- #define CUR_TIME (*(unsigned long*)0x20C)
- #define FINDER_NAME ((char*)0x2E0)
- #define CurDirStore (*(long *)(0x398))
- #define SFSaveDisk (*(short *)(0x214))
- #define MenuList (*(Handle*)0xA1C)
-
- #define true ((char)1)
- #define false ((char)0)
-
- #define kEnter (0x03)
- #define kReturn (0x0D)
- #define kTab (0x09)
- #define kESC (0x1B)
- #define kUpArrow (0x1E)
- #define kDownArrow (0x1F)
- #define kLeftArrow (0x1C)
- #define kRightArrow (0x1D)
- #define kBackspace (0x08)
- #define kHelp (0x05)
- #define kDelete (0x7F)
- #define kHome (0x01)
- #define kEnd (0x04)
- #define kPgUp (0x0B)
- #define kPgDown (0x0C)
-
- #define ioDirFlg (0x10)
- #define TopMapHndl (*(Handle *)0xA50) /* 1st map in resource list [Handle] */
- #define HIWORD(aLong) ((short)(((aLong) >> 16) & 0xFFFF))
- #define LOWORD(aLong) ((short)((aLong) & 0xFFFF))
-
- #define SETRECT(rectp, _left, _top, _right, _bottom) \
- ((rectp)->left = ((short)(_left)), (rectp)->top = ((short)(_top)), \
- (rectp)->right = ((short)(_right)), (rectp)->bottom = ((short)(_bottom)))
-
- #define INSETRECT(rectp, _dh, _dv) \
- ((rectp)->left += ((short)(_dh)), (rectp)->top += ((short)(_dv)), \
- (rectp)->right -= ((short)(_dh)), (rectp)->bottom -= ((short)(_dv)))
-
- #define SETPT(pt, _h, _v) ((pt)->h = (_h), (pt)->v = (_v))
-
-
-
- // •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
-
- typedef long StringCompareMethod;
-
- typedef struct
- {
- StringCompareMethod method;
- Str255 str;
- } StringSpec, *StringSpecPtr, **StringSpecHdl;
-
- #endif
-